<?php

 /**
  * @package JooS
  * @subpackage CodeGenerator_File
  */

  class JooS_CodeGenerator_File {
    /**
     * @var JooS_CodeGenerator_File_Adapter
     */
    private $_adapter = null;

    /**
     * @param string $adapter
     */
    public function __construct($adapter = null) {
      if ($adapter !== null)
        $this->setAdapter(self::createAdapter($adapter));
    }

    /**
     * @param JooS_CodeGenerator_File_Adapter|string $name
     * @return JooS_CodeGenerator_File_Adapter
     */
    public static function createAdapter($name) {
      require_once "JooS/CodeGenerator/File/Adapter.php";
      return JooS_CodeGenerator_File_Adapter::newInstance($name);
    }

    /**
     * @param JooS_CodeGenerator_File_Adapter $adapter
     * @return JooS_CodeGenerator_File
     */
    public function setAdapter(JooS_CodeGenerator_File_Adapter $adapter) {
      $this->_adapter = $adapter;
      return $this;
    }

    /**
     * @return JooS_CodeGenerator_File_Adapter
     */
    public function getAdapter() {
      return $this->_adapter;
    }

    protected static function throwException($Message, $Code = 0) {
      require_once "JooS/CodeGenerator/File/Exception.php";

      throw new JooS_CodeGenerator_File_Exception($Message, $Code);
    }
  }
